<!-- 组织机构管理 -->
<div class="easyui-layout" >

    <div class="easyui-tabs" style="height:700px;padding: 20px;">

        <div title="股票排行榜" style="padding:10px">
            <div style="margin:20px 0;">

                <div id="stock_rank_toolbar" style="padding:5px;height:auto">
                    <form action="" id="stock_rank_form">
                        <select id="stock_rank_week" class="easyui-combobox" name="weeks" style="width:200px;">
                            <option value="1" selected>1周</option>
                            <option value="2">2周</option>
                            <option value="3">3周</option>
                            <option value="4">4周</option>
                        </select>

                        <select id="stock_rank_topnums" class="easyui-combobox" name="tops" style="width:200px;">
                            <option value="10" selected>top10</option>
                            <option value="20">top20</option>
                            <option value="50">top50</option>
                            <option value="100">top100</option>
                        </select>
                        行业:
                        <input id="stock_rank_industy" class="easyui-combobox" name="industry_name"
                               data-options="valueField:'value',textField:'name',url:'/board/industry-info'" value=''/>
                        <a href="#" id="stock_rank_search">Search</a>

                    </form>
                </div>
                <div id="stock_top_tb" style="margin:20px 0;">

                </div>

            </div>
        </div>
    </div>

</div>

<script type="text/javascript" src="/web/static/js/index.js"></script>
<script type="text/javascript">


    $('#stock_rank_search').linkbutton({  //查询按钮
        iconCls: "icon-search"
    });

    $('#stock_rank_search').click(function () {

        $.ajax({
            /*type = "get",*/
            url: '/stock/fund/ranking',
            data: {
                'weeks': $("#stock_rank_week").val(),
                'tops': $("#stock_rank_topnums").val(),
                'industry_name': $("#stock_rank_industy").val(),
            },
            dateType: "JSON",
            success: function (data, textStatus, jqXHR) {
                const groupList = groupBy(data, function (item) {
                    return [item.groupname];//按照name进行分组
                });

                {#对原数组进行转置#}
                newGroup = spiltGroup(groupList)

                $("#stock_top_tb").empty();

                var table = $("<table class='datagrid-table' cellpadding='0' cellspacing='0' border='1'>");
                table.appendTo($("#stock_top_tb"));
                {#表头#}
                var caption = $('<caption>股票单日排行榜</caption>');
                caption.appendTo(table)
                {#表头#}
                var thead = $("<thead></thead>")
                thead.appendTo(table);

                for (let groupDate in groupList) {
                    var th = $("<th class='datagrid-header-row' style='padding: 2px;margin: 2px;'>" + groupDate + "</th>");
                    th.appendTo(thead)
                }

                for (var i = 0; i < newGroup.length; i++) {
                    var tr = $("<tr class='datagrid-row'  align='center' style='padding: 2px;margin: 2px;'></tr>");
                    tr.appendTo(table);
                    for (var j = 0; j < newGroup[i].length; j++) {
                        let stock = newGroup[i][j];
                        var msg = '净流入:' + stock.main_net_inflow + ';涨跌幅:' + stock.pctChg + ';换手率:' + stock.turn + ';PE:' + stock.PE + ';';
                        {#var href_url = 'http://quote.eastmoney.com/bk/90.' + stock.industry_code + '.html'#}
                        var td = $("<td ondblclick='alert(\"" + msg + "\")'> " + stock.stock_name + ':(' + stock.main_net_inflow + ")</td>");
                        td.appendTo(tr);
                    }
                }
                {#trend.appendTo(table);#}
                $("#stock_top_tb").append("</table>");

            }
        });

    });


</script>
